#!/usr/bin/python
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""GIT account status response

Wrapper for the account status checking responses. It builds the JSON response
which is sent back to the identity toolkit widget.
"""

__author__ = 'Xin Zhou(zhounew@google.com)'

from git.json import git_json
from git.logic import git_base_response

class GitAccountStatusResponse(git_base_response.GitBaseResponse):
  def __init__(self):
    self.registered_ = ''
    self.legacy_ = ''
    self.display_name_ = ''
    self.photo_url_ = ''
    self.json_ = {}
  
  def SetDisplayName(self, display_name):
    self.display_name_ = display_name
  
  def SetPhotoUrl(self, photo_url):
    self.photo_url_ = photo_url
  
  def SetLegacy(self, legacy):
    self.legacy_ = legacy
  
  def SetRegistered(self, registered):
    self.registered_ = registered
  
  def ToJson(self):
    json = {}
    if self.display_name_:
      json['displayName'] = self.display_name_
    if self.photo_url_:
      json['photoUrl'] = self.photo_url_
    json['registered'] = self.registered_
    json['legacy'] = self.legacy_
    return git_json.GitJson().dumps(json)